﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;

namespace FRL.DebtChased.Repository
{

	/// <summary>
	/// Extensions to the LetterType model
	/// </summary>
	public partial class LetterType
	{

		/////////////////////////////////////////////////////////////
		// Constants and enumerations

		[Flags]
		public enum eDays
		{
			NotSet		= 0x00,
			Monday		= 0x01,
			Tuesday		= 0x02,
			Wednessday	= 0x04,
			Thursday	= 0x08,
			Friday		= 0x10,
			Saturday	= 0x20,
			Sunday		= 0x40,
			AllDays		= (Sunday<<1)-1,
			Immediate	= 0xF000,
		}

		/////////////////////////////////////////////////////////////
		// Attributes

		public eDays Days
		{
			get { return (eDays)this.DayFlags; }
			set { this.DayFlags = (int) value; }
		}

		/////////////////////////////////////////////////////////////
		// Static Operations

		public static Dictionary<int, string> GetDictionary(DebtChasedEntities ent, bool bAddNoneOption)
		{

			// Load the letter-types
			var results = from lt in ent.LetterTypes
						  orderby lt.Name
						  select new { lt.LetterTypeId, lt.Name };

			// Declare return
			Dictionary<int, string> Ftmp = new Dictionary<int, string>();

			// If adding none...
			if (bAddNoneOption)
				Ftmp.Add(0, Definitions.None);

			// Add results
			foreach (var ob in results)
				Ftmp.Add(ob.LetterTypeId, ob.Name);

			// Return variable
			return Ftmp;

		}


		public static Dictionary<int, string> GetDaysDictionary()
		{

			// Declare return variable
			Dictionary<int, string> Ftmp = new Dictionary<int, string>();

			// Add says to dictionary
			Ftmp.Add((int)eDays.Monday, eDays.Monday.ToString());
			Ftmp.Add((int)eDays.Tuesday, eDays.Tuesday.ToString());
			Ftmp.Add((int)eDays.Wednessday, eDays.Wednessday.ToString());
			Ftmp.Add((int)eDays.Thursday, eDays.Thursday.ToString());
			Ftmp.Add((int)eDays.Friday, eDays.Friday.ToString());
			Ftmp.Add((int)eDays.Saturday, eDays.Saturday.ToString());
			Ftmp.Add((int)eDays.Sunday, eDays.Sunday.ToString());

			// Return variable
			return Ftmp;

		}

	}

}
